package com.aspose.cells;

import java.util.ArrayList;
import java.util.Iterator;

class zant {
   private WorksheetCollection b;
   private Worksheet c;
   private ShapeCollection d;
   private zqa e;
   private zjp f;
   private ArrayList g;
   byte[] a;

   zant(WorksheetCollection var1, Worksheet var2, ShapeCollection var3, zqa var4) {
      this.b = var1;
      this.c = var2;
      this.d = var3;
      this.e = var4;
      this.g = new ArrayList();
      this.b();
   }

   private void b() {
      int var1 = 0;
      Iterator var2 = this.d.iterator();

      while(var2.hasNext()) {
         Shape var3 = (Shape)var2.next();
         switch(var3.getAutoShapeType()) {
         case 19:
            var1 += 16;
         case 20:
         case 21:
         case 22:
         case 23:
         case 24:
         case 25:
         case 26:
         case 27:
         case 28:
         case 29:
         case 30:
         case 31:
         case 53:
         case 54:
         case 55:
         case 56:
         case 57:
         case 58:
         case 59:
         case 60:
         case 64:
         case 65:
         case 66:
         case 67:
         case 68:
         case 69:
         case 70:
         case 71:
         case 72:
         case 73:
         case 74:
         case 75:
         case 76:
         case 82:
         case 84:
         case 85:
         case 86:
         case 87:
         case 88:
         case 89:
         case 90:
         case 91:
         case 92:
         case 93:
         case 94:
         case 95:
         case 96:
         case 97:
         case 98:
         case 99:
         case 100:
         case 101:
         case 102:
         case 103:
         case 104:
         case 105:
         case 107:
         case 108:
         case 109:
         case 110:
         case 111:
         case 112:
         case 113:
         case 114:
         case 115:
         case 116:
         case 117:
         case 118:
         case 119:
         case 120:
         case 121:
         case 122:
         case 123:
         case 124:
         case 125:
         case 126:
         case 127:
         case 128:
         case 129:
         case 130:
         case 131:
         case 132:
         case 133:
         case 134:
         case 135:
         case 136:
         case 137:
         case 138:
         case 139:
         case 140:
         case 141:
         case 142:
         case 143:
         case 144:
         case 145:
         case 146:
         case 147:
         case 148:
         case 149:
         case 150:
         case 151:
         case 152:
         case 153:
         case 154:
         case 155:
         case 156:
         case 157:
         case 158:
         case 159:
         case 160:
         case 161:
         case 162:
         case 163:
         case 164:
         case 165:
         case 166:
         case 167:
         case 168:
         case 169:
         case 170:
         case 171:
         case 172:
         case 173:
         case 174:
         case 175:
         case 176:
         case 177:
         default:
            break;
         case 32:
         case 33:
         case 34:
         case 35:
         case 36:
         case 37:
         case 38:
         case 39:
         case 40:
            var1 += 32;
            break;
         case 41:
         case 42:
         case 43:
         case 44:
         case 45:
         case 46:
         case 47:
         case 48:
         case 49:
         case 50:
         case 51:
         case 52:
         case 61:
         case 62:
         case 63:
         case 77:
         case 78:
         case 79:
         case 80:
         case 81:
         case 83:
         case 106:
         case 178:
         case 179:
         case 180:
         case 181:
            var1 += 16;
         }
      }

      if (var1 != 0) {
         this.a = new byte[var1 + 8];
         this.a[0] = 31;
         this.a[2] = 5;
         this.a[3] = -16;
         System.arraycopy(com.aspose.cells.b.a.zc.a(var1), 0, this.a, 4, 4);
         int var7 = 8;
         byte[] var8 = new byte[]{-1, -1, -1, -1, -1, -1, -1, -1};

         for(int var4 = 0; var4 < this.d.getCount(); ++var4) {
            Shape var5 = this.d.get(var4);
            switch(var5.getAutoShapeType()) {
            case 19:
               this.a[var7 + 2] = 20;
               this.a[var7 + 3] = -16;
               this.a[var7 + 4] = 8;
               System.arraycopy(com.aspose.cells.b.a.zc.a(var5.N().i().b()), 0, this.a, var7 + 8, 4);
               System.arraycopy(com.aspose.cells.b.a.zc.a(var5.N().i().b()), 0, this.a, var7 + 12, 4);
               var1 += 16;
            case 20:
            case 21:
            case 22:
            case 23:
            case 24:
            case 25:
            case 26:
            case 27:
            case 28:
            case 29:
            case 30:
            case 31:
            case 53:
            case 54:
            case 55:
            case 56:
            case 57:
            case 58:
            case 59:
            case 60:
            case 64:
            case 65:
            case 66:
            case 67:
            case 68:
            case 69:
            case 70:
            case 71:
            case 72:
            case 73:
            case 74:
            case 75:
            case 76:
            case 82:
            case 84:
            case 85:
            case 86:
            case 87:
            case 88:
            case 89:
            case 90:
            case 91:
            case 92:
            case 93:
            case 94:
            case 95:
            case 96:
            case 97:
            case 98:
            case 99:
            case 100:
            case 101:
            case 102:
            case 103:
            case 104:
            case 105:
            case 107:
            case 108:
            case 109:
            case 110:
            case 111:
            case 112:
            case 113:
            case 114:
            case 115:
            case 116:
            case 117:
            case 118:
            case 119:
            case 120:
            case 121:
            case 122:
            case 123:
            case 124:
            case 125:
            case 126:
            case 127:
            case 128:
            case 129:
            case 130:
            case 131:
            case 132:
            case 133:
            case 134:
            case 135:
            case 136:
            case 137:
            case 138:
            case 139:
            case 140:
            case 141:
            case 142:
            case 143:
            case 144:
            case 145:
            case 146:
            case 147:
            case 148:
            case 149:
            case 150:
            case 151:
            case 152:
            case 153:
            case 154:
            case 155:
            case 156:
            case 157:
            case 158:
            case 159:
            case 160:
            case 161:
            case 162:
            case 163:
            case 164:
            case 165:
            case 166:
            case 167:
            case 168:
            case 169:
            case 170:
            case 171:
            case 172:
            case 173:
            case 174:
            case 175:
            case 176:
            case 177:
            default:
               break;
            case 32:
            case 33:
            case 34:
            case 35:
            case 36:
            case 37:
            case 38:
            case 39:
            case 40:
               this.a[var7] = 1;
               this.a[var7 + 2] = 18;
               this.a[var7 + 3] = -16;
               this.a[var7 + 4] = 24;
               var7 += 8;
               zmk var6 = var5.f;
               System.arraycopy(com.aspose.cells.b.a.zc.a(var5.N().i().b()), 0, this.a, var7, 4);
               System.arraycopy(com.aspose.cells.b.a.zc.a(var5.N().i().b()), 0, this.a, var7 + 12, 4);
               if (var6 != null && var6.a != -1 && var6.c != -1) {
                  System.arraycopy(com.aspose.cells.b.a.zc.a(this.d.get(var6.a).N().i().b()), 0, this.a, var7 + 4, 4);
                  System.arraycopy(com.aspose.cells.b.a.zc.a(this.d.get(var6.c).N().i().b()), 0, this.a, var7 + 8, 4);
                  System.arraycopy(com.aspose.cells.b.a.zc.a(var6.b), 0, this.a, var7 + 16, 4);
                  System.arraycopy(com.aspose.cells.b.a.zc.a(var6.d), 0, this.a, var7 + 20, 4);
               } else {
                  System.arraycopy(var8, 0, this.a, var7 + 16, 8);
               }

               var7 += 24;
               break;
            case 41:
            case 42:
            case 43:
            case 44:
            case 45:
            case 46:
            case 47:
            case 48:
            case 49:
            case 50:
            case 51:
            case 52:
            case 61:
            case 62:
            case 63:
            case 77:
            case 78:
            case 79:
            case 80:
            case 81:
            case 83:
            case 106:
            case 178:
            case 179:
            case 180:
            case 181:
               this.a[var7 + 2] = 23;
               this.a[var7 + 3] = -16;
               this.a[var7 + 4] = 8;
               System.arraycopy(com.aspose.cells.b.a.zc.a(var5.N().i().b()), 0, this.a, var7 + 8, 4);
               System.arraycopy(com.aspose.cells.b.a.zc.a(var5.N().i().b()), 0, this.a, var7 + 12, 4);
               var7 += 16;
            }
         }

      }
   }

   void a() throws Exception {
      boolean var1 = true;
      Iterator var2 = this.d.iterator();

      Shape var3;
      while(var2.hasNext()) {
         var3 = (Shape)var2.next();
         var3.N().l();
      }

      var2 = this.d.iterator();

      while(var2.hasNext()) {
         var3 = (Shape)var2.next();
         if (!var3.S()) {
            if (var3.isGroup()) {
               this.a((GroupShape)var3, var1);
            } else if (var3.U()) {
               this.a(var3, var1);
            } else {
               this.b(var3, var1);
            }

            var1 = false;
         }
      }

      if (this.a != null) {
         byte[] var6 = this.a;
         if (var6.length <= 8224) {
            this.e.b(236);
            this.e.b(var6.length);
            this.e.a(var6);
            return;
         }

         int var7 = 0;
         boolean var4 = false;
         zamr var5 = new zamr(this);

         while(true) {
            int var8 = var6.length - var7;
            if (var8 <= 8224) {
               var5.a(var6, var7, var8);
               var5.a(this.e);
               break;
            }

            var5.a(var6, var7, 8224);
            var5.a(this.e);
            var7 += 8224;
         }
      }

   }

   void a(GroupShape var1, boolean var2) throws Exception {
      this.b(var1, var2);
      var2 = false;
      Shape[] var3 = var1.getGroupedShapes();
      Shape[] var4 = var3;
      int var5 = var3.length;

      for(int var6 = 0; var6 < var5; ++var6) {
         Shape var7 = var4[var6];
         if (var7.isGroup()) {
            this.a((GroupShape)var7, var2);
         } else {
            this.b(var7, var2);
         }
      }

      this.g.remove(this.g.size() - 1);
   }

   void a(Shape var1, boolean var2) throws Exception {
      zamr var3 = new zamr(this);
      int var4 = 0;
      if (var2) {
         var4 = var3.a(this.d, var1);
      }

      ComboBox var5 = (ComboBox)var1;
      int var7;
      int var8;
      zapf var9;
      int var10;
      if (var5.a() instanceof AutoFilter) {
         AutoFilter var6 = (AutoFilter)var5.a();
         var7 = var6.g();
         var8 = var6.h().StartColumn;
         var9 = new zapf();

         int var11;
         for(var10 = var1.K(); var8 <= var6.h().EndColumn; var8 = var11) {
            var11 = var8 + 1;
            zani var12 = this.c.getCells().q();

            for(int var13 = 0; var13 < var12.getCount(); ++var13) {
               CellArea var14 = var12.a(var13);
               if ((var7 & '\uffff') >= var14.StartRow && (var7 & '\uffff') <= var14.EndRow && var8 >= var14.StartColumn && var8 <= var14.EndColumn) {
                  if (var14.EndColumn > var6.h().EndColumn) {
                     var11 = var6.h().EndColumn + 1;
                  } else {
                     var11 = var14.EndColumn + 1;
                  }
                  break;
               }
            }

            var5.N().i().b(var5.N().i().b() + 1);
            var3.a(var5, var4, var7, var8, var11);
            var3.a(this.e);
            var9.a(var1, var10++);
            var9.a(this.e);
            var4 = 0;
            if (var8 == 255) {
               break;
            }
         }
      } else if (var5.a() instanceof ValidationCollection) {
         String var15 = var5.M().getActiveCell();
         byte var17 = 0;
         byte var18 = 0;
         int[] var19 = new int[]{var17};
         int[] var21 = new int[]{var18};
         CellsHelper.a(var15, var19, var21);
         var7 = var19[0];
         var8 = var21[0];
         var3.a(var5, var4, var7, (byte)var8);
         var3.a(this.e);
         zapf var22 = new zapf();
         var22.a(var1, var1.K());
         var22.a(this.e);
      } else if (var5.a() instanceof PivotTable) {
         PivotTable var16 = (PivotTable)var5.a();
         var7 = var16.i;
         byte var20 = (byte)(var16.k + 1);
         var9 = new zapf();
         var10 = var1.K();
         PivotFieldCollection var24 = var16.getPageFields();

         for(int var23 = 0; var23 < var24.getCount(); ++var23) {
            var7 = var16.i - 1 - (var24.getCount() - var23);
            var5.N().i().b(var5.N().i().b() + 1);
            var3.a(var5, var4, var7, var20 & 255, (byte)((var20 & 255) + 1) & 255);
            var3.a(this.e);
            var9.a(var1, var10++);
            var9.a(this.e);
            var4 = 0;
            if ((var20 & 255) == 255) {
               break;
            }
         }
      }

   }

   void b(Shape var1, boolean var2) throws Exception {
      zamr var3 = new zamr(this);
      int var4 = 0;
      if (var2) {
         var4 = var3.a(this.d, var1);
      }

      var3.a(var1, var4, this.g);
      var3.a(this.e);
      zapf var5 = new zapf();
      var5.a(var1);
      var5.a(this.e);
      if (var1.D() || var1.getMsoDrawingType() == 5) {
         this.a(var1);
      }

   }

   void a(Shape var1) throws Exception {
      switch(var1.getMsoDrawingType()) {
      case 2:
         this.a(var1, ((RectangleShape)var1).aa());
         break;
      case 3:
         this.a(var1, ((Oval)var1).aa());
         break;
      case 4:
         this.a(var1, ((ArcShape)var1).aa());
         break;
      case 5:
         if (this.f == null) {
            this.f = new zjp(this.b, this.c.m(), this.c.getCharts(), this.e);
         }

         this.f.a(((ChartShape)var1).a());
         break;
      case 6:
         this.a(var1, ((TextBox)var1).aa());
         break;
      case 7:
         this.a(var1, ((Button)var1).aa());
      case 8:
      case 9:
      case 10:
      case 13:
      case 15:
      case 16:
      case 17:
      case 18:
      case 20:
      case 21:
      case 22:
      case 23:
      case 24:
      case 26:
      case 27:
      case 28:
      case 29:
      default:
         break;
      case 11:
         this.a(var1, ((CheckBox)var1).aa());
         break;
      case 12:
         this.a(var1, ((RadioButton)var1).aa());
         break;
      case 14:
         this.a(var1, ((Label)var1).aa());
         break;
      case 19:
         this.a(var1, ((GroupBox)var1).aa());
         break;
      case 25:
         this.a(var1, ((CommentShape)var1).a().b());
         break;
      case 30:
         this.a(var1, ((CellsDrawing)var1).aa());
      }

   }

   void a(Shape var1, zbtz var2) throws Exception {
      zamr var3 = new zamr(this);
      var3.a();
      var3.a(this.e);
      zbsd var4 = new zbsd();
      int var5 = 0;
      if (var2.i() != null && !"".equals(var2.i())) {
         var5 = var2.i().length() & '\uffff';
      }

      int var6 = var2.n();
      ArrayList var7 = var4.a(var1, var2, var6, var5);
      var4.a(this.e);
      if (var5 != 0) {
         zmo var8 = new zmo();
         var8.a(var2.i(), this.e);
         var8.a(this.e);
         var8.a(var7);
         var8.a(this.e);
      }
   }
}
